// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import Axios from 'axios'
import App from './App'
import router from './router'

import store from './store'

Vue.config.productionTip = false

// router.beforeEach((to, from, next) => {
//   if (to.matched.some(route => route.meta.requiresAuth)) {
//     if (!store.getters.loggedIn) {
//       next({
//         name: 'Login'
//       })
//     }
//   } else {
//     next()
//   }
// })

//拦截器和loading实现
Axios.interceptors.response.use(
  config => {
    store.state.showLoading = true
    return config
  },
  error => {
    store.state.showLoading = false
  }
)

Axios.interceptors.response.use(
  response => {
    store.state.showLoading = false
    return response
  },
  error => {
    store.state.showLoading = false
    return response
  }
)

new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
